# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=volatility-extra
pkgver=92.d9fc072
pkgrel=4
pkgdesc='Volatility plugins developed and maintained by the community.'
groups=('blackarch' 'blackarch-forensic')
arch=('any')
url='https://github.com/volatilityfoundation/community'
license=('custom:unknown')
depends=('python2' 'python2-pefile' 'python2-yara' 'volatility3')
makedepends=('git')
source=("$pkgname::git+https://github.com/volatilityfoundation/community.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  rm -rf FrancescoPicasso ProcessFuzzyHash MichaelBrown \
    FrankBlock PeterCasey JavierVallejo BartoszInglot \
    LorenzLiebler Citronneur AFF4 AlexanderTarasenko \
    AlizHammond TakahiroHaruyama LoicJaquemet MarcinUlikowski
  # will decrease and fix

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec /usr/bin/volatility --plugins="/usr/share/$pkgname" "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

